{%     for ifd in device_abstract_config.get('physical_interfaces', []) %}
{%         if feature in ifd.get('comment', '') %}
{%             if ifd.name != 'lo0' %}
set groups {{cfg_group}} interfaces {{ifd.name}} mtu 9192
delete protocols rstp interface {{ifd.name}}
{%         endif %}
{%             for ifl in ifd.get('logical_interfaces', []) %}
delete interfaces {{ifd.name}} unit {{ifl.unit}}
set interfaces {{ifd.name}} unit {{ifl.unit}} family inet
{%                 set address = ifl.ip_addresses[0].address %}
{%                 if ifl.name == 'lo0.0' %}
set groups {{cfg_group}} interfaces {{ifd.name}} unit {{ifl.unit}} family inet address {{address}}/32
{%                 else %}
set groups {{cfg_group}} interfaces {{ifd.name}} unit {{ifl.unit}} family inet address {{address}}/30
{%                 endif %}
{%             endfor %}
{%         endif %}
{%     endfor %}

{%     set loopback_ip_list = device_abstract_config.get('system', {}).get('loopback_ip_list', []) %}
{%     if loopback_ip_list|length > 0 %}
{%         set loopback_ip = loopback_ip_list[0] %}
{%         if loopback_ip %}
set groups {{cfg_group}} routing-options router-id {{loopback_ip}}
set groups {{cfg_group}} routing-options route-distinguisher-id {{loopback_ip}}
{%         endif %}
{%     endif %}

{%     for bgp in device_abstract_config.get('bgp', []) %}
{%         if feature in bgp.get('comment', '') %}
set groups {{cfg_group}} protocols bgp log-updown
set groups {{cfg_group}} protocols bgp graceful-restart
{%             set bgp_group_name = "IPCLOS_eBGP" %}
set groups {{cfg_group}} protocols bgp group {{bgp_group_name}} type external
set groups {{cfg_group}} protocols bgp group {{bgp_group_name}} mtu-discovery
set groups {{cfg_group}} protocols bgp group {{bgp_group_name}} multipath multiple-as
set groups {{cfg_group}} protocols bgp group {{bgp_group_name}} export IPCLOS_BGP_EXP
set groups {{cfg_group}} protocols bgp group {{bgp_group_name}} import IPCLOS_BGP_IMP
set groups {{cfg_group}} protocols bgp group {{bgp_group_name}} bfd-liveness-detection minimum-interval 350
set groups {{cfg_group}} protocols bgp group {{bgp_group_name}} bfd-liveness-detection multiplier 3
set groups {{cfg_group}} protocols bgp group {{bgp_group_name}} bfd-liveness-detection session-mode automatic
set groups {{cfg_group}} protocols bgp group {{bgp_group_name}} local-as {{bgp.autonomous_system}}
set groups {{cfg_group}} protocols bgp group {{bgp_group_name}} vpn-apply-export
{%             for peer in bgp.get('peers', []) %}
set groups {{cfg_group}} protocols bgp group {{bgp_group_name}} neighbor {{peer.ip_address}}
set groups {{cfg_group}} protocols bgp group {{bgp_group_name}} neighbor {{peer.ip_address}} description {{peer.comment}}
set groups {{cfg_group}} protocols bgp group {{bgp_group_name}} neighbor {{peer.ip_address}} peer-as {{peer.autonomous_system}}
{%             endfor %}
set groups {{cfg_group}} policy-options policy-statement PFE-LB then load-balance per-packet
set groups {{cfg_group}} policy-options policy-statement IPCLOS_BGP_EXP term loopback from protocol direct
set groups {{cfg_group}} policy-options policy-statement IPCLOS_BGP_EXP term loopback from protocol bgp
set groups {{cfg_group}} policy-options policy-statement IPCLOS_BGP_EXP term loopback then accept
set groups {{cfg_group}} policy-options policy-statement IPCLOS_BGP_EXP term default then reject
set groups {{cfg_group}} policy-options policy-statement IPCLOS_BGP_IMP term loopback from protocol bgp
set groups {{cfg_group}} policy-options policy-statement IPCLOS_BGP_IMP term loopback from protocol direct
set groups {{cfg_group}} policy-options policy-statement IPCLOS_BGP_IMP term loopback then accept
set groups {{cfg_group}} policy-options policy-statement IPCLOS_BGP_IMP term default then reject

set groups {{cfg_group}} routing-options forwarding-table export PFE-LB
set groups {{cfg_group}} routing-options forwarding-table ecmp-fast-reroute
{%         endif %}
{%     endfor %}
